﻿using System;
using System.Globalization;
using System.Reflection;

namespace Entropy.Ext
{
	public class ParamAsPropertyInfo : PropertyInfo
	{
		private readonly string name;
		private readonly bool isJson;
		private readonly Type propertyType;

		public ParamAsPropertyInfo(Type propertyType, string name, bool isJson)
		{
			this.propertyType = propertyType;
			this.name = name;
			this.isJson = isJson;
		}

		public override object[] GetCustomAttributes(bool inherit)
		{
			return new object[0];
		}

		public override string ToString()
		{
			var s = "name";
			if (isJson)
				s += " (isJson)";
			return s;
		}

		public override bool IsDefined(Type attributeType, bool inherit)
		{
			return false;
		}

		public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
		{
			return null;
		}

		public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
		{
		}

		public override MethodInfo[] GetAccessors(bool nonPublic)
		{
			return new MethodInfo[0];
		}

		public override MethodInfo GetGetMethod(bool nonPublic)
		{
			return null;
		}

		public override MethodInfo GetSetMethod(bool nonPublic)
		{
			return null;
		}

		public override ParameterInfo[] GetIndexParameters()
		{
			return new ParameterInfo[0];
		}

		public override string Name
		{
			get { return name; }
		}


		public override Type DeclaringType
		{
			get { return null; }
		}

		public override Type ReflectedType
		{
			get { return typeof(object); }
		}

		public override Type PropertyType
		{
			get { return propertyType; }
		}

		public override PropertyAttributes Attributes
		{
			get { return new PropertyAttributes(); }
		}

		public override bool CanRead
		{
			get { return true; }
		}

		public override bool CanWrite
		{
			get { return false; }
		}

		public override object[] GetCustomAttributes(Type attributeType, bool inherit)
		{
			return new object[0];
		}
	}
}